package com.groupnections.server.database.solution;

import java.util.ArrayList;
import java.util.List;

public class ConvertDatabaseToSolution {

	public static List<com.groupnections.shared.entities.Solution> getSolutions(
			List<Solution> solutionsDatabase) {

		List<com.groupnections.shared.entities.Solution> solutions = new ArrayList<com.groupnections.shared.entities.Solution>();

		for (Solution solutionDatabase : solutionsDatabase) {

			com.groupnections.shared.entities.Solution solution = new com.groupnections.shared.entities.Solution();
			solutions.add(getSolution(solutionDatabase));
		}

		return solutions;
	}

	public static com.groupnections.shared.entities.Solution getSolution(
			Solution databaseSolution) {

		com.groupnections.shared.entities.Solution solution = new com.groupnections.shared.entities.Solution();

		if (databaseSolution.getSolutionID() != null) {

			solution.setSolutionID(databaseSolution.getSolutionID().getId());
		}

		if (databaseSolution.getDescription() != null) {

			solution.setDescription(databaseSolution.getDescription()
					.getValue());
		}

		if (databaseSolution.getTags() != null) {

			solution.setTags(databaseSolution.getTags().getValue());
		}

		return solution;
	}
}
